/**
 * Copyright (c)  HeiFeiDeFengZheng.Co.Ltd. All rights reserved.
 **/
package com.dexin.warehousedemo.common;

import lombok.Data;

/**
 * 功能描述：
 *
 * @author huifeidefengzheng
 * @since 2024-01-15
 **/
@Data
public class Result {

    private int code;
    private String msg;
    private Object data;
    private Long total;
    private Long pageSize;

    private static Result result(int code, String msg, Object data) {
        Result result = new Result();
        result.setCode(code);
        result.setData(data);
        result.setMsg(msg);
        return result;
    }

    private static Result result(int code, String msg, Object data, Long total, Long pageSize) {
        Result result = new Result();
        result.setCode(code);
        result.setData(data);
        result.setMsg(msg);
        result.setTotal(total);
        result.setPageSize(pageSize);
        return result;
    }

    public static Result fail() {
        return result(500, "error", null);
    }

    public static Result suc() {
        return result(200, "success", null);
    }

    public static Result suc(Object data) {
        return result(200, "success", data);
    }

    public static Result suc(Object data, Long total, Long pageSize) {
        return result(200, "success", data, total, pageSize);
    }

    public static Result suc(Object data, Long total) {
        return result(200, "success", data, total, null);
    }

    public static Result fail(String msg) {
        return result(500, msg, null);
    }
}
